<?php

$this->breadcrumbs = array(
	$model->label(2) => array('index'),
	Yii::t('app', 'Manage'),
);

$this->menu = array(
		array('label'=>'New User', 'url'=>array('create'),
            'linkOptions'=> array('class' => 'icon icon-user-plus tb-gray'),
        ),
        array('label'=>'Export to Excel', 'url'=>array('excelexport'),
            'linkOptions'=> array('class' => 'icon icon-download5 tb-gray'),
        ),
        array('label'=>'Print to PDF', 'url'=>array('pdfexport'),
            'linkOptions'=> array('class' => 'icon icon-printer2 tb-gray'),
        ),

	);

?>


<h2 class="form-header">
    <?php
    echo CHtml::encode($this->pageTitle);

    $pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);
    $pagesizehtml = CHtml::dropDownList(
        'pageSize',$pageSize,BCApp::GetPageSizeArray(),
        array(
            'onchange'=>"$.fn.yiiGridView.update('user-grid',{ data:{pageSize: $(this).val() }})",
        )
    );

    echo "<div class=\"page-size\">Results per page: ".$pagesizehtml."</div>";
    ?>

</h2>


<?php


$this->widget('zii.widgets.grid.CGridView', array(
	'id' => 'user-grid',
	'dataProvider' => $model->search(),
	'filter' => $model,
    'summaryText' => '',
    'pager' => Array(
        'firstPageLabel'=>'<<',
        'prevPageLabel'=>'<',
        'nextPageLabel'=>'>',
        'lastPageLabel'=>'>>',
    ),
    'selectionChanged'=>"function(id){window.location='" . Yii::app()->urlManager->createUrl('user/view', array('id'=>'')) . "' + $.fn.yiiGridView.getSelection(id);}",
	'columns' => array(
		'username',
		'fullname',
		'email',
		array(
				'name'=>'user_role_id',
				'value'=>'GxHtml::valueEx($data->userRole)',
				'filter'=>GxHtml::listDataEx(UserRole::model()->findAllAttributes(null, true)),
				),
		'last_login',
		array(
					'name' => 'locked',
					'value' => '($data->locked == 0) ? Yii::t(\'app\', \'No\') : Yii::t(\'app\', \'Yes\')',
					'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
					),
        array(
            'class' => 'CButtonColumn',
            'template' => '{view}&nbsp;{delete}',
            'buttons' => array(
                'view' => array(
                    'imageUrl'=>'',
                    'label' => '',
                    'options'=>array('class'=>'icon icon-pencil4 grid-gray'),
                ),
                'delete' => array(
                    'imageUrl'=>'',
                    'label' => '',
                    'options'=>array('class'=>'icon icon-cancel-circle2 grid-gray'),
                ),
            )
        ),

	),
)); ?>